package test.luin.pers.myapplication;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

public class MyService2 extends Service {
    public MyService2() {

    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.i("BindService", "onBind)被调用");
        MyBinder myBinder = new MyBinder();
        Log.i("Service", "绑定服务成功,地址为"+myBinder.toString());
        return myBinder;
    }

    class MyBinder extends Binder {
        public void callMehtod() {
            methodInService();
            Log.i("BindService", "d调用内部方法callMehtod()");
        }
    }

    public void methodInService() {
        Log.i("BindService", "自定义方法methodInService()被调用");
    }

    @Override
    public void onCreate() {

        super.onCreate();
        Log.i("Service", "创建服务成功onCreate()");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("Service", "销毁onDestroy()");

    }


}
